package com.nlp.visualization.common;

import com.nlp.visualization.core.seg.SegmentType;
import com.nlp.visualization.core.seg.filter.SegFilter;
import com.nlp.visualization.utils.PropertyUtil;
import org.apache.commons.collections.map.HashedMap;

import java.io.File;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CONSTANTS {

    public static String CSV_PATH = "/Users/lxm/MyComputer/temp/TeacherWang_weibo_data/needParse/try.csv";
    public static String JSON_PATH = "/Users/lxm/MyComputer/temp/TeacherWang_weibo_data/needParse/json.json";

    //微博scv的头
    public static String[] WEIBO_CSV_HEADERS = new String[]{"_id", "is_message", "user_id", "weibo_id", "weibo_info"};


    //多线程处理的任务数量
    public static int TASK_MAX = 100;
    public static int TASK_TIMEOUT = 1200;


    //分词的信息
    public static int STATUS = 0;                 //状态码
    public static String VERSION = "HANLP_1.5.3_NLP";   //分词的版本信息


    //分词数据库的表名信息
    public static String WEIBO_CONTENT_TABLE_NAME = "t_weibo_content";
    public static String WEIBO_CONTENT_TABLE_ID = "weibo_id";
    public static String WEIBO_CONTENT_TABLE_CONTENT = "weibo_content";
    public static Map<Integer, String> TABLE_NAME_HASH_MAP;


    //默认的分词方式与默认的过滤器
    public static SegmentType SEGMENT_TYPE = SegmentType.HANLP_NLP;
    private static SegFilter.FilterBuilder builder = new SegFilter.FilterBuilder();
    public static SegFilter FILTER_NO = builder.enableStopwords(false).enablePunctuation(false).build();
    public static SegFilter FILTER_YES = builder.enableStopwords(true).enablePunctuation(true).build();


    static {
        TABLE_NAME_HASH_MAP = new HashMap<Integer, String>();
        TABLE_NAME_HASH_MAP.put(0, "t_weibo_user_mod_0_seg");
        TABLE_NAME_HASH_MAP.put(1, "t_weibo_user_mod_1_seg");
        TABLE_NAME_HASH_MAP.put(2, "t_weibo_user_mod_2_seg");
        TABLE_NAME_HASH_MAP.put(3, "t_weibo_user_mod_3_seg");
        TABLE_NAME_HASH_MAP.put(4, "t_weibo_user_mod_4_seg");
        TABLE_NAME_HASH_MAP.put(5, "t_weibo_user_mod_5_seg");
        TABLE_NAME_HASH_MAP.put(6, "t_weibo_user_mod_6_seg");
        TABLE_NAME_HASH_MAP.put(7, "t_weibo_user_mod_7_seg");
        TABLE_NAME_HASH_MAP.put(8, "t_weibo_user_mod_8_seg");
        TABLE_NAME_HASH_MAP.put(9, "t_weibo_user_mod_9_seg");

    }

    //启动多线程分词的条件
    public static final int MULTI_THREAD_SIZE = 1000;


    //错误代码集合
    public static final int ERROR_SUCCESS = 0;
    public static final int ERROR_UNKNOWN = 999;
    public static final int ERROR_PARAM_ERROR = 700;
    public static final int ERROR_UPLOAD = 800;
    public static final int ERROR_WRONG_PSW = 501;


//    词云背景图片
//    public static final String BACKGROUND_IMAGE_PATH = PropertyUtil.getInstance("config").getProperty("word-cloud-image-path");
//    词云保存路径
//    public static final String WORDCLOUD_SAVE_PATH = PropertyUtil.getInstance("config").getProperty("word-cloud-image-output-path");
//    项目上下文路径
//    public static String CONTEXT =PropertyUtil.getInstance("config").getProperty("context.path");

    //项目上下文路径
    public static String CONTEXT;
    //词云背景图片
    public static String BACKGROUND_IMAGE_PATH;

    static {
        try {
            CONTEXT = new File(CONSTANTS.class.getResource("/").toURI().getPath()).getParentFile().getParentFile().getPath();
            BACKGROUND_IMAGE_PATH = CONSTANTS.class.getResource("/").toURI().getPath() + "/images/";
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
    }

    //词云保存路径
    public static final String WORDCLOUD_SAVE_PATH = PropertyUtil.getInstance("config").getProperty("word-cloud-image-output-path");


    //爬虫配置数据
    //重试次数
    public static int CRAWLER_RETRY_TIME = 3;
    //重试间隔时间
    public static int CRAWLER_RETRY_WAITING_TIME = 1000;
    //线程数量
    public static int CRAWLER_THREAD_COUNT = 20;
    //最新新闻的接口
    public static final String NETEASY_URL = "http://news.163.com/special/0001220O/news_json.js";
    public static final String SINA_URL = "http://roll.news.sina.com.cn/interface/rollnews_ch_out_interface.php?col=89&offset_num=0&num=100000&page=1";
    public static final String SINA_URL2 = "http://feed.mix.sina.com.cn/api/roll/get?pageid=382&lid=48&k=&num=50&page=1&r=0.3181548977574089&callback=jQuery3110648365510386298_1520318748376&_=1520318748378";
    public static final String QQ_URL = "";
    public static final String SOUHU_URL = "";
    //各个接口，顺序：科技、体育、军事、财经、娱乐、国际社会、健康、图书、教育、政治、社会、娱乐、电影、科技、教育
    private String edu = "http://top.edu.sina.com.cn/ws/GetTopDataList.php?top_type=day&top_cat=edu_suda&top_time=today&top_show_num=1000&top_order=desc&js_var=edu_suda_1_data&call_back=showContent";
    public static String[] SINA_CHANNELS = {"http://roll.news.sina.com.cn/interface/rollnews_ch_out_interface.php?col=96&spec=&type=&ch=01&k=&offset_page=0&offset_num=0&num=3000&asc=&page=1&r=0.9939514011516022",
            "http://roll.news.sina.com.cn/interface/rollnews_ch_out_interface.php?col=94&spec=&type=&ch=01&k=&offset_page=0&offset_num=0&num=3000&asc=&page=1&r=0.4843086192488075"
            , "http://roll.news.sina.com.cn/interface/rollnews_ch_out_interface.php?col=93&spec=&type=&ch=01&k=&offset_page=0&offset_num=0&num=3000&asc=&page=1&r=0.032602716459375625"
            , "http://roll.news.sina.com.cn/interface/rollnews_ch_out_interface.php?col=97&spec=&type=&ch=01&k=&offset_page=0&offset_num=0&num=2000&asc=&page=1&r=0.6351815888076009"
            , "http://feed.mix.sina.com.cn/api/roll/get?pageid=382&lid=48&k=&num=3000&page=1&r=0.3181548977574089&callback=jQuery3110648365510386298_1520318748376&_=1520318748378"
            , "http://feed.mix.sina.com.cn/api/roll/get?pageid=382&lid=48&k=&num=5000&page=1&r=0.3181548977574089&callback=jQuery3110648365510386298_1520318748376&_=1520318748378"
            , "http://roll.news.sina.com.cn/interface/rollnews_ch_out_interface.php?col=91&spec=&type=&ch=01&k=&offset_page=0&offset_num=0&num=3000&asc=&page=1&r=0.36106959272305716"
            , "http://feed.mix.sina.com.cn/api/roll/get?pageid=39&lid=561&num=3000&versionNumber=1.2.8&page=1&encode=utf-8&callback=feedCardJsonpCallback&_=1520319135249"
            , "http://feed.mix.sina.com.cn/api/roll/get?callback=jsonp1520319366692&pageid=8&lid=137&num=2000&page=1"
            , "http://roll.news.sina.com.cn/interface/rollnews_ch_out_interface.php?col=90&spec=&type=&ch=01&k=&offset_page=0&offset_num=0&num=2000&asc=&page=1&r=0.8599673814323758"
            , "http://roll.news.sina.com.cn/interface/rollnews_ch_out_interface.php?col=92&spec=&type=&ch=01&k=&offset_page=0&offset_num=0&num=3000&asc=&page=1&r=0.5289869780210554"
            , "http://feed.mix.sina.com.cn/api/roll/get?pageid=375&lid=2462&num=3000&versionNumber=1.2.8&page=1&encode=utf-8&callback=feedCardJsonpCallback&_=1520760166885"
            , "http://feed.mix.sina.com.cn/api/roll/get?pageid=51&lid=740&num=3000&versionNumber=1.2.8&page=1&encode=utf-8&callback=feedCardJsonpCallback&_=1520760361654"
            , "http://feed.mix.sina.com.cn/api/roll/get?pageid=48&lid=25&num=3000&versionNumber=1.2.8&page=1&encode=utf-8&callback=feedCardJsonpCallback&_=1520760418134"
            , "http://cre.mix.sina.com.cn/get/cms/feed?callback=jQuery111207047737645759478_1520760668800&cre=tianyi&mod=pceduc&merge=3&statics=1&length=120&up=0&down=0&tm=1520760668&action=0&top_id=%2C4g4v6%2C4gFqi%2C%2C%2C4g5ru%2C4fzRt%2C4gIYr%2C4gU4I%2C4gaz3%2C%2C4ToAn%2C4gdh9%2C%2C4gaqk%2C%2C4gi49%2C4gUwu%2C%2C4etjR%2C3wAcp%2C%2C4gaVE%2C4evEo%2C4etE0%2C4hS0h%2C&offset=0&ad=%7B%22rotate_count%22%3A100%2C%22platform%22%3A%22pc%22%2C%22channel%22%3A%22tianyi_pcedu%22%2C%22page_url%22%3A%22http%3A%2F%2Fedu.sina.com.cn%2F%22%2C%22timestamp%22%3A1520760668813%7D&pcProduct=75&_=1520760668802"
            , "http://cre.mix.sina.com.cn/api/v3/get?callback=jQuery111207047737645759478_1520760668800&cre=tianyi&mod=pcedu&merge=3&statics=1&length=120&up=0&down=0&tm=1520760678&action=0&top_id=%2C4g4v6%2C4gFqi%2C%2C%2C4g5ru%2C4fzRt%2C4gIYr%2C4gU4I%2C4gaz3%2C%2C4ToAn%2C4gdh9%2C%2C4gaqk%2C%2C4gi49%2C4gUwu%2C%2C4etjR%2C3wAcp%2C%2C4gaVE%2C4evEo%2C4etE0%2C4hS0h%2C&offset=0&ad=%7B%22rotate_count%22%3A100%2C%22platform%22%3A%22pc%22%2C%22channel%22%3A%22tianyi_pcedu%22%2C%22page_url%22%3A%22http%3A%2F%2Fedu.sina.com.cn%2F%22%2C%22timestamp%22%3A1520760668813%7D&cateid=I&_=1520760668803"
    };
    //LDA缓存文件的目录
    public static final String TEXT_TEMP = PropertyUtil.getInstance("config").getProperty("lda.text.temp");


    //贝叶斯模型的标签
    public static List BAYES_MODELS_LIST = new ArrayList();


    static {
        Map<String, String> BAYES_MODEL_TAGS_MAP;
        BAYES_MODEL_TAGS_MAP = new HashedMap();
        BAYES_MODEL_TAGS_MAP.put("name", "酒店评论");
        BAYES_MODEL_TAGS_MAP.put("tag", "3AA0496FD96F3EBD27EF493C0D242469");
        BAYES_MODELS_LIST.add(BAYES_MODEL_TAGS_MAP);
        BAYES_MODEL_TAGS_MAP = new HashedMap();
        BAYES_MODEL_TAGS_MAP.put("name", "社区评论");
        BAYES_MODEL_TAGS_MAP.put("tag", "621E171B116936A9C45679A2A0DB4C49");
        BAYES_MODELS_LIST.add(BAYES_MODEL_TAGS_MAP);
        BAYES_MODEL_TAGS_MAP = new HashedMap();
        BAYES_MODEL_TAGS_MAP.put("name", "图书评论");
        BAYES_MODEL_TAGS_MAP.put("tag", "DCC209DFC41E8C0EAC41A99BF4D943FC");
        BAYES_MODELS_LIST.add(BAYES_MODEL_TAGS_MAP);
        BAYES_MODEL_TAGS_MAP = new HashedMap();
        BAYES_MODEL_TAGS_MAP.put("name", "知网情感语料");
        BAYES_MODEL_TAGS_MAP.put("tag", "8CB97B845FBDFA6EEE02E6E05941E110");
        BAYES_MODELS_LIST.add(BAYES_MODEL_TAGS_MAP);
        BAYES_MODEL_TAGS_MAP = new HashedMap();
        BAYES_MODEL_TAGS_MAP.put("name", "电影评论(英文)");
        BAYES_MODEL_TAGS_MAP.put("tag", "E72A243A56AF61131A45803E8CA1A6A2");
        BAYES_MODELS_LIST.add(BAYES_MODEL_TAGS_MAP);
    }


}
